load("//:pkg-externals.bzl", "PKG_EXTERNALS")
load("//src/cdk:config.bzl", "CDK_ENTRYPOINTS")
load("//src/cdk-experimental:config.bzl", "CDK_EXPERIMENTAL_ENTRYPOINTS")
load("//src/material:config.bzl", "MATERIAL_ENTRYPOINTS", "MATERIAL_TESTING_ENTRYPOINTS")
load("//src/material-experimental:config.bzl", "MATERIAL_EXPERIMENTAL_ENTRYPOINTS", "MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS")
load("@npm//:defs.bzl", "npm_link_all_packages")

package(default_visibility = ["//visibility:public"])

exports_files([
    "LICENSE",
    "package.json",
])

npm_link_all_packages(
    name = "node_modules",
)

# Target which writes the list of package externals into a JSON file so that the
# Starlark-configured externals (for the NPM package bundling) can be passed to
# the `check-package-externals` Yarn script, which validates our module imports.
genrule(
    name = "package_externals",
    outs = ["package_externals.json"],
    cmd = "echo '%s' > $@" % PKG_EXTERNALS,
)

entryPoints = ["cdk/%s" % e for e in CDK_ENTRYPOINTS] + \
              ["cdk-experimental/%s" % e for e in CDK_EXPERIMENTAL_ENTRYPOINTS] + \
              ["material/%s" % e for e in MATERIAL_ENTRYPOINTS + MATERIAL_TESTING_ENTRYPOINTS] + \
              ["material-experimental/%s" % e for e in MATERIAL_EXPERIMENTAL_ENTRYPOINTS + MATERIAL_EXPERIMENTAL_TESTING_ENTRYPOINTS]

genrule(
    name = "entry_points_manifest",
    outs = ["entry_points_manifest.json"],
    cmd = "echo '%s' > $@" % entryPoints,
)
